#include <iostream>
#include <queue>
#include <vector>

using namespace std;

struct CompareByFirst {
    constexpr bool
    operator()(pair<int, int> const &a, pair<int, int> const &b) const noexcept {
        return a.first < b.first;
    }
};

int main() {
    priority_queue<pair<int, int>, std::vector<std::pair<int, int>>, CompareByFirst> a;
    pair<int, int> b(12, 2);
    pair<int, int> c(1, 3);
    pair<int, int> d(21, 5);
    a.push(d);
    a.push(c);
    a.push(b);
    while (!a.empty()) {
        cout << a.top().first << ' ' << a.top().second << '\n';
        a.pop();
    }
}
